home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 37
/
Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso
/
Aminet
/
dev
/
misc
/
AWNP_2-39.lha
/
AWNP
/
AWNP-Docs
/
Tutorials
/
tutorial2.rx
< prev
next >
Wrap
Text File
|
1999-10-31
|
4KB
|
173 lines
/*Tutorial 2 for AWNPipe*/
call setdefaults()
call buildgui()
do while ~eof(ca)
in= readln(ca)
parse var in in1 in2 in3 in4 .
if in1='gadget' then call gadget()
if in1='menu' then call menu()
if in1='close' then call windowclosed()
end
exit
gadget:
if in2=agegad then age=in3 Close
if in2=sexgad then sex=in3
if in2=knogad then knowledge=in3
if in2=basgad then basic=in3
if in2=aregad then arexx=in3
if in2=cgad then c=in3
if in2=asmgad then asm=in3
/* the return from a string gadget is parsed differently since it can be more
then 1 word. */
if in2=namegad then do
parse var in . . in3
name=in3
end
if in2=dongad then do
call printdata()
exit
end
if in2=resgad then do
call close(ca)
call setdefaults()
call buildgui()
end
if in2=cangad then do
say 'user canceled'
exit
end
return
windowclosed:
say 'User aborted with CTRL BackSlash or closed window.'
exit
return
menu:
/* menu 0 is just informational so can be ignored */
if in2=1 then do
if in3=0 then call printdata()
if in3=1 then do
if in4=0 then say 'name' name 'age' age 'sex' sex
if in4=1 then say 'knowledge' knowledge 'basic' basic 'arexx' arexx 'c' c 'asm' asm
end
end
return
setdefaults:
name='unset'
age=30
sex=0
knowledge=0
basic=0
c=0
asm=0
arexx=0
return
buildgui:
/* Open pipe 'tut2' with GUI creation option '/xc' */
call open(ca,"awnpipe:tut2/xc")
/* define the window */
/* The first line oF every GUI is the window definition. The window is titled
"Tutorial 2" and its elements will be laid out verticaly (v). It has a
closegadget (cg) , depthgadget (dg) , and dragbar (db). It will have spaces
inbetween its gadgets (si). It will open on the topleft (tl) of the screen
becoming active (a) when opened. */
call topipe(' "Tutorial 2" v cg dg db si a tl')
/* define the gadgets*/
call topipe(' layout b 0 v')
/* Labels are used to tell the user what information to enter in each gadget.
These labels are unatached (ua) when they are defined so don't go directly
into the GUI. Instead they are attached to the following gadget by the
childlabel (chl) keyword. */
call topipe(' label gt "Name: " ua')
namegad=topipe('string chl')
call topipe(' label gt "Age: " ua')
agegad=topipe('integer chl minn 5 maxn 115 arrows defn 30 weiw 0')
call topipe(' label gt "Sex: " ua')
sexgad=topipe('radiobutton rl "Male|Female" chl')
call topipe(' label gt "Knowledge: " ua')
knogad=topipe('chooser pu cl "Novice|Average|Good|Expert" chl')
call topipe(' label gt "Language(s): " ua')
call topipe(' layout b 0 chl')
basgad=topipe('checkbox gt "Basic " chl')
aregad=topipe('checkbox gt "Arexx " chl')
cgad=topipe('checkbox gt "C " chl')
asmgad=topipe('checkbox gt "ASM " chl')
call topipe(' le')
call topipe(' le')
call topipe(' layout si so')
resgad= topipe('button gt "Reset Form" c')
dongad= topipe('button gt "Done" c')
cangad= topipe('button gt "Cancel" c')
call topipe(' le')
call topipe(' menu gt "Project |About|$! Tutorial 2 |$! AWNPipe: Example"')
call topipe(' menu gt "Data|@AShow all data|Show part|$@PPersonal|$@SSkill"')
/*open the GUI window*/
call topipe("open")
return
printdata:
/*show the value of all the gadgets*/
say ' Name: 'name
say ' Age: 'age
say ' Sex: 'sex
say 'Knowledge: 'knowledge
if basic=1 then say ' Basic'
if arexx=1 then say ' Arexx'
if c=1 then say ' C'
if asm=1 then say ' Asm'
return
topipe:
/* this routine does error checking on lines written to pipe.*/
/*get line to output*/
parse arg out
/* write to the pipe*/
call writeln(ca,out)
/*get responce and parse it.*/
res=readln(ca)
parse var res res1 res2 .
/* if all is ok return the second part of the responce (usualy the GID)*/
if res1='ok' then return(res2)
/* something went wrong, we notify the user then exit */
/*show problem line and responce (reponce may be just a blank line)*/
say 'error from: 'out
say ' responce: ' in
exit